#!/bin/zsh

logfile=/private/var/log/fwcld.log

time_formatted=$(date "+%Y-%m-%d %H:%M:%S.***")

function log_me {
	echo "$time_formatted|main|INFO|CLIENT|$1"  >> "$logfile"
}

function block_me {
	pgrep -x "$1"
	if [ $? -eq 0 ]
	then
		proc_id=$(pgrep -x "$1")
		proc_info=$(ps -o comm= -p $proc_id)
		
		log_me "User attempted to run blocked app: $proc_info"
		log_me "Killing: $1"
		pkill -x "$1"
	fi
}